<template>
  <el-form ref="formRef" :model="form" >
    <pub-edit-description :ndColumns="2">
      <pub-edit-description-item :span="2" label="关联功能" required>
        <el-form-item prop="relateCode" :rules="$formRules.select">
          <pub-select-dict
            width="100%"
            v-model="form.relateCode"
            dict-code="SPKJYMK"
            placehoder="请选择"
          ></pub-select-dict>
        </el-form-item>
      </pub-edit-description-item>
      <pub-edit-description-item :span="2" label="快捷语" required>
        <el-form-item prop="quickName" :rules="$formRules.input">
          <pub-textarea v-model="form.quickName" />
        </el-form-item>
      </pub-edit-description-item>
    </pub-edit-description>
  </el-form>

  <div class="dialog-footer-btn">
    <el-button type="default" @click="emit('cancel')">取消</el-button>
    <el-button type="primary" @click="submit" v-prevent-repeat-click>
      保存
    </el-button>
  </div>
</template>
<script setup>
import { ElLoading } from 'element-plus'
import { add_kjy } from '../api'
import { formatDictCode } from '@/utils/index'
const emit = defineEmits(['cancel', 'success'])

const form = ref({})
const formRef = ref(null)
const submit = async () => {
  formRef.value.validate(async valid => {
    if (valid) {
      console.log(form.value)
      let res = await add_kjy(form.value)
      if (res.succeed) {
        emit('success')
      }
    }
  })
}
onMounted(() => {})
</script>
<style lang="scss" scoped></style>
